﻿using ArtMath.Core.Data;
using ArtMath.Core.Helper;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;

namespace ArtMath.Helper
{
    public static class Painter
    {
        public static void DrawStraightLine(this Graphics gra, SketchPad pad, Pen p, PointD Plocation, double Pslope)
        {
            double pkAngle = double.IsNaN(Pslope) ? 0 : Math.Atan(Pslope) * Core.Helper.Angle.RToD;
            Core.Helper.Painter.Transform(gra, Plocation, pkAngle, () =>
            {
                PointD len = Utility.CalcLength(PointD.FromPoint(pad.PxyToMouseLocation(Plocation)) / pad.Zoom.ToPointD(),
                    pad.PSize, Angle.DegreeRound - pkAngle);
                gra.DrawLine(p, (float)-len.X, 0, (float)len.Y, 0);
            });
        }
        public static void DrawStraightLine(this Graphics gra, SketchPad pad, PointD Plocation, double Pslope)
        {
            gra.DrawStraightLine(pad, Core.Helper.Painter.VirtualLinePen, Plocation, Pslope);
        }
        public static void DrawRay(this Graphics gra, SketchPad pad, Pen p, PointD Plocation, double PdirectedAngle)
        {
            Core.Helper.Painter.Transform(gra, Plocation, PdirectedAngle, () =>
            {
                PointD len = Utility.CalcLength(PointD.FromPoint(pad.PxyToMouseLocation(Plocation)) / pad.Zoom.ToPointD(),
                    pad.PSize, Angle.DegreeRound - PdirectedAngle);
                gra.DrawLine(p, 0, 0, (float)len.Y, 0);
            });
        }
        public static void DrawRay(this Graphics gra, SketchPad pad, PointD Plocation, double PdirectedAngle)
        {
            gra.DrawRay(pad, Core.Helper.Painter.VirtualLinePen, Plocation, PdirectedAngle);
        }
    }
}
